package com.xuanwei.xwcommon.enums;

/**
 * @Author jiangyong
 * @Description TODO
 * @Date 2019/6/28 16:16
 **/
public enum  ProductListOrderType {

    CREATE_TIME(1,"createTime","创建时间"),

    PRICE(2,"minPrice","价格"),

    STOCK(3,"stock","库存"),

    SEAL_NUM(4,"saleNum","销量");

    private Integer code;

    private String msg;

    private String field;

    ProductListOrderType(Integer code,String filed, String msg) {
        this.code = code;
        this.msg = msg;
        this.field =filed;
    }

    public String getField() {
        return field;
    }

    public void setField(String field) {
        this.field = field;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static String getCode(Integer code){
        ProductListOrderType[] values = ProductListOrderType.values();
        for (ProductListOrderType type:values
             ) {
            if(type.code.equals(code)){
                return type.getField();
            }
        }
        return ProductListOrderType.PRICE.getField();
    }

}
